package colltection;
import java.util.*;

public class SortString {
    public static void main(String[] args) {
     /**   List <String> list =new ArrayList<>();
        list.add("abd");
        list.add("Khasod");
        list.add("123sadi");
        list.add("_sada");
        list.add("-asd");
        System.out.println(list);//根据ASCII码排序
        System.out.println("升序后："+list);*/
     List<String> list=new ArrayList<>();
     list.add("王克晶");
     list.add("亚斯娜给");
     list.add("阿萨德");
     list.add("王克晶老师");
        Collections.sort(list);
        System.out.println(list);
        Collections.sort(list, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.length()-o2.length();
            }//o1-o2是升序,o2-o1是降序
        });
        System.out.println(list);
    }
}
